from collections import Counter
class Solution:
    def minAnagramLength(self, s: str) -> int:
        leng = len(s)
        for i in range(1, leng):
            if leng % i == 0:
                flag = True
                str_dict = Counter(s[:i])
                for j in range(i, leng, i):
                    if Counter(s[j:j+i]) != str_dict:
                        flag = False
                        break
                if flag == True:
                    return i
        return leng

if __name__ == "__main__":
    s = Solution()
    print(s.minAnagramLength("abba"))
    print(s.minAnagramLength("cdef"))
    print(s.minAnagramLength("aabfccafab"))
    